# -*- coding: utf-8 -*-
# @Time : 2025/6/25 上午9:19
# @Author : cc 
# @Email : liuchenchen@starmerx.com
# @Project : my-tools
# @Desc : 功能描述


from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
import cv2

ocr_recognition = pipeline(Tasks.ocr_recognition, model='iic/cv_convnextTiny_ocr-recognition-general_damo')

# ### 使用url
img_url = 'http://duguang-labelling.oss-cn-shanghai.aliyuncs.com/mass_img_tmp_20220922/ocr_recognition.jpg'
result = ocr_recognition(img_url)
print(result)

### 使用图像文件
### 请准备好名为'ocr_recognition.jpg'的图像文件
img_path = 'a.png'
img = cv2.imread(img_path)
result = ocr_recognition(img)
print(result)